package com.ibm.spatiotemp.server.config;

import java.util.Random;

public class PubSubMetaVector {
	public static int DefaultMaxSize = 100;

	private Random rand = new Random();

	private int maxLength;
	
	private PubSubMeta[] vector;
	
	private int cursize;
	
	public PubSubMetaVector(int maxsize){
		vector = new PubSubMeta[maxsize];
		this.maxLength = maxsize;
	}
	
	public boolean addMetaVector(PubSubMeta meta)
	{
		if(cursize + 1 < maxLength){
			vector[cursize++] = meta;
			return true;
		}
		else
			return false;
	}
	
	private PubSubMeta selectVector(int index)
	{
		return vector[index];
	}
	
	public PubSubMeta selectPubSubMeta_Random(){
		int idx = rand.nextInt(cursize);
		return selectVector(idx);
	}
	
}
